package tp.pr5.instructions;

import tp.pr5.NavigationModule;
import tp.pr5.RobotEngine;
import tp.pr5.instructions.exceptions.InstructionExecutionException;
import tp.pr5.instructions.exceptions.WrongInstructionFormatException;
import tp.pr5.items.ItemContainer;

public class QuitInstruction extends UndoAble{
	private RobotEngine rbt;
	@Override
	public Instruction parse(String cad) throws WrongInstructionFormatException {
		if(cad.equalsIgnoreCase("QUIT") || cad.equalsIgnoreCase("SALIR")){//si la acciÃ³n introducida es QUIT
			return new QuitInstruction();
		}else{
			throw new WrongInstructionFormatException();
		}
	}

	@Override
	public String getHelp() {
		return "     QUIT|SALIR";
	}

	@Override
	public void configureContext(RobotEngine engine,
			NavigationModule navigation, ItemContainer robotContainer) {
		this.rbt = engine;
		
	}

	@Override
	public void execute() throws InstructionExecutionException {
		//System.out.println("WALLÂ·E says: I have communication problems. Bye bye"+Main.LINE_SEPARATOR);
		rbt.requestQuit();
	}

	@Override
	public boolean isUndoAble() {

		return false;
	}
	/**
	 * revets the las instruction
	 */
	
}
